/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package personInfoTests;

import model.Constants;
import model.personInfo.Contacts;
import model.personInfo.Name;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.*;

/**
 *
 * @author Slayer
 */
public class NameTest {
    private Name name;
    
    private final String FIRST_NAME = "Vasya";
    private final String LAST_NAME = "Ivanov";
    
    private final String SEPARATOR = Constants.LINE_SEPARATOR;
    
    public NameTest() {
    }
    
    @Before
    public void setUp() {
        name = new Name(FIRST_NAME, LAST_NAME);
    }
    
    @After
    public void tearDown() {
    }
    
    @Test(expected=IllegalArgumentException.class)
    public void shouldThrowIllegalArgumentExceptionWhenPassNullFirstName() {
        name = new Name(null, LAST_NAME);
    }
    
    @Test
    public void shouldReturnFirstNameWhenGet() {
        //given
        String expected = FIRST_NAME;
        //then
        assertEquals(expected, name.getFirstName());
    }
    
    @Test
    public void shouldReturnLastNameWhenGet() {
        //given
        String expected = LAST_NAME;
        //then
        assertEquals(expected, name.getLastName());
    }
    
    @Test
    public void testToString() {
        //given
        String expected = "First name: " + FIRST_NAME + SEPARATOR + 
                          "Last name: " + LAST_NAME + SEPARATOR;
        //then
        assertEquals(expected, name.toString());
    }
    
    @Test
    public void testClone() {
        //given
        String expected = name.toString();
        //then
        assertEquals(expected, name.clone().toString());
    }
    
    @Test
    public void testEquals() {
        //given
        Name expected = name;
        //then
        assertEquals(expected, name.clone());
    }
}
